package io.gitee.kotle.demo.mvvm_demo.pic

import android.content.Context
import android.os.Bundle
import androidx.core.os.bundleOf
import io.gitee.kotle.android.delegate.bundleDelegate
import io.gitee.kotle.android.utils.BlurTransformation
import io.gitee.kotle.android.utils.setImageByCoil
import io.gitee.kotle.android.utils.startFragment
import io.gitee.kotle.base.library.BaseBindingFragment
import io.gitee.kotle.demo.databinding.FragmentPicBlurBinding

class PicBlurFragment : BaseBindingFragment<FragmentPicBlurBinding>() {
    companion object {
        fun start(context: Context, pic: String) {
            context.startFragment<PicBlurFragment>(
                arguments = bundleOf(
                    "pic" to pic
                )
            )
        }
    }

    private val pic by bundleDelegate("pic", "")

    override fun initUi(savedInstanceState: Bundle?) {
        super.initUi(savedInstanceState)
        mBinding.root.setImageByCoil(pic) {
            it.transformations(BlurTransformation(20))
            it.placeholderMemoryCacheKey(pic.replace("https://cn.bing.com/", ""))
        }
    }

    override fun initObserverLiveData() {
        super.initObserverLiveData()
    }

    override fun initData() {
        super.initData()
    }
}